package com.ghxxzx.dagl.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ghxxzx.dagl.entity.Daxx;
import com.ghxxzx.dagl.entity.DaxxWs;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public interface DaxxWsMapper extends BaseMapper<DaxxWs> {
    @Select("SELECT * FROM daxx_ws")
    List<DaxxWs> findAll();

    @Select("SELECT * FROM `daxx_ws` where dabh=#{dabh} LIMIT 1")
    DaxxWs findByDabh(String dabh);

    @Select("SELECT id FROM `daxx_ws` WHERE `nf`<=#{stopNf} AND `nf` >=#{startNf} and type_id=#{typeId}")
    List<DaxxWs> findByYear(@Param("startNf") int startyear,@Param("stopNf") int stopyear,@Param("typeId") Integer id);

    @Select("SELECT MAX(nf) FROM daxx_ws")
    String findByMaxYear();

    @Select("SELECT `nf` FROM daxx_ws WHERE type_id=#{typeId} GROUP BY `nf`")
    ArrayList<String> findGroupByYear(@Param("typeId") Integer typeId);

    @Select("SELECT type_id FROM daxx_ws WHERE dabh=#{dabh}")
    Integer findByDanbh(@Param("dabh")String dabh);
}
